package com.ysy.tz.mfg.utils;

import com.ysy.tz.core.engine.KeyValuePair;
import java.util.Iterator;
import java.util.List;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.TableColumn;
import javafx.scene.control.cell.PropertyValueFactory;

public class DefaultPropertyValueFactory<S, T> extends PropertyValueFactory<S, T> {
    List<? extends KeyValuePair> keyValuePairs;

    public DefaultPropertyValueFactory(String property, List<? extends KeyValuePair> keyValuePairs) {
        super(property.substring(3));
        this.keyValuePairs = keyValuePairs;
    }

    public ObservableValue<T> call(TableColumn.CellDataFeatures<S, T> param) {
        ObservableValue<T> t = super.call(param);
        Iterator var3 = this.keyValuePairs.iterator();

        KeyValuePair keyValuePair;
        do {
            if (!var3.hasNext()) {
                return null;
            }

            keyValuePair = (KeyValuePair)var3.next();
        } while(!keyValuePair.getKeyPair().equals(t.getValue()));

        return new ReadOnlyObjectWrapper(keyValuePair.getValuePair());
    }
}
